﻿@model IEnumerable<IPublishItem>

@{
    ViewBag.Title = "Новости";    
}

@section tabmenu
{    
    <ul class="tabs group">
        <li>@Html.ActionLink("Главная", "List", "Heroes")</li>
        <li class="active">@Html.ActionLink("Новости", "List", "News")</li>
        <li>@Html.ActionLink("Арты", "Shops", "Items")</li>
        <li>@Html.ActionLink("Форум", "List", "Forum")</li>
        <li><a href="http://vk.com/club20418573" target="_blank">Группа ВК</a></li>
    </ul>    
}


<h2>@if (!ViewBag.isPartial) {<text>Новости на </text> @ViewBag.onDate.ToShortDateString()} else {
        @Html.ActionLink("Новости на " + (string)ViewBag.onDate.ToShortDateString(), "List")
   }</h2>

<div>
    <ul class="submenu" style="display:inline">
       <li class="main">@Html.ActionLink("Добавить новость", "Add", "Forum", new { isNews = true }, null)</li>
       <li>@Html.ActionLink("Все новости", "List", new { on = ViewBag.onDate})</li>

       @foreach (string key in ViewBag.ItemsKeys)
       { 
            <li>@Html.ActionLink(key, "List", new { type = key, on = ViewBag.onDate })</li>
       }
    </ul>
</div>

@foreach (var item in Model)
{
    <div style="margin: 20px 0px; padding:10px; border:1px dashed gray">
        @if (item is Topic) { Html.RenderAction("One", "Forum", new { topic = (Topic)item, showComments = true }); }
        else if (item is Guide) { Html.RenderAction("One", "Guides", new { guide = (Guide)item, showComments = true }); }
        else if (item is Purchase) { Html.RenderAction("OneObject", "Purchases", new { purchase = (Purchase)item, showComments = true }); }
        else if (item is Upgrade) { Html.RenderAction("OneObject", "Upgrades", new { upgrade = (Upgrade)item, showComments = true }); }
        else if (item is Command) { Html.RenderAction("One", "Commands", new { command = (Command)item, showComments = true }); }
    </div>
}

<div style="margin-top:50px">
@Html.ActionLink("Назад в прошлое на один день", "List", new { type = ViewBag.type, on = (ViewBag.onDate as DateTime?).Value.Date.AddDays(-1) })
</div>


@using (Html.BeginForm("List", "News", new { type = ViewBag.type }, FormMethod.Get, new { id = "datepickerForm", style="margin-top:15px"}))
{ 
    <div id="datepicker"></div>
    @Html.Hidden("on")    
}

<script type="text/javascript">
    $(function () {
        $("#datepicker").datepicker({
            onSelect: function (dateText, inst) {
                $("#on").val(dateText);
                $("#datepickerForm").submit();
            }
        });
        $('#datepicker > .ui-datepicker').show();  
    });
</script>
